package com.jy.api.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

/**
 * Created by hanxi on 2018/9/17.
 */
@Data
public class PaymentChannelStatics {
    private String channel;
    private long qty;
    private double amount;

    public PaymentChannelStatics(String channel, long qty, double amount) {
        this.channel = channel;
        this.qty = qty;
        this.amount = amount;
    }

    @JsonIgnore
    public String getParentChannel() {
        if (channel.startsWith("pay")) {
            return channel.split("\\.")[1];
        } else if (channel.endsWith("CASH")) {
            return "CASH";
        } else {
            return channel;
        }
    }

}
